﻿@using EasyCourse.Model;
@{
    Layout = null;

    var courseOtherInfo = ViewData["CourseOtherInfo"] as CourseOtherInfo;
    ViewData["TypeCode"] = courseOtherInfo.TypeCode;
    var courseOtherInfoTypeDic = CourseOtherInfoManage.Instance.CourseOtherInfoTypeDic;
    CommonPageInfo pageInfo = ViewData[CommonViewDataKey.CommonPageInfo] as CommonPageInfo;
    string para = "CourseId=" + courseOtherInfo.CourseId;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>精品课程管理</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav4Teacher.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">
                @CourseInfoManage.Instance.GetCourseNameById(courseOtherInfo.CourseId)<br>
                <small>广州中医药大学康复治疗微课程网络学习平台</small>
            </h1>
        </div>
    </div>
    @*导航菜单*@
    @Html.Partial("~/Views/Share/PublicTeacherNaviMenu.cshtml", 0)
    <div class="container">
        <div class="row">
            @Html.Partial("~/Views/Share/PublicCourseOtherInfoMenu.cshtml", this.ViewData)
            <div class="col-xs-10">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            <ol class="breadcrumb">
                                <li>@courseOtherInfoTypeDic[courseOtherInfo.TypeCode.Value]</li>
                                <li class="active">@courseOtherInfo.Title</li>
                            </ol>
                        </h3>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <form class="form-horizontal" role="form">
                                <div class="form-group">
                                    <div class="col-xs-12">
                                        <a href="@Url.Action("CourseOtherInfoContentAdd", "CourseOtherInfo")?PId=@courseOtherInfo.Id&CourseId=@courseOtherInfo.CourseId&TypeCode=@courseOtherInfo.TypeCode" class="btn btn-success btn-md"><span class="glyphicon glyphicon-plus"></span>新增 </a>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="row">
                            <table class="table table-bordered tb1 table-striped table-hover">
                                <thead>
                                    <tr>
                                        <th width="30%">栏目名称</th>
                                        <th width="20%">创建时间</th>
                                        <th width="30%">是否停用</th>
                                        <th width="20%">操作</th>
                                    </tr>
                                </thead>
                                <tbody id="tbody"></tbody>
                            </table>
                        </div>
                        <div class="row clearfix well d-page">
                            <div id="PagInfo" class="pull-left sum">
                            </div>
                            <div class="clearfix pull-right">
                                <ul id="PageTool" class="pagination"></ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicFooter.cshtml")
    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
    <script>
        var tbody = $("#tbody");
        var options = false;
        var _state = false;
        var _courseOtherInfoId = "@courseOtherInfo.Id";
        function getList(pageNo) {
            $("#PagInfo").html("");
            $("#PageTool").html("");

            $.easyPost("/CourseOtherInfo/GetCourseOtherInfoContentList", { "PageNO": pageNo, "PageSize": "10", "CourseOtherInfoId": _courseOtherInfoId },
               function (data) {
                   if (!data.result) {
                       showTips.open(data.message);
                       return;
                   }
                   var _html = '';
                   if (data.rows.length > 0) {
                       $(".d-page").show();
                       var _row = data.rows,
                           _rowL = _row.length;
                       options = {
                           totalPages: data.totalPage,
                           total: data.total,
                           currentPage: pageNo,
                           onPageClicked: function (event, originalEvent, type, page) {
                               getList(page);
                           }
                       }
                       initialPaginator(options, "PageTool", "PagInfo");

                       for (var i = 0; i < _rowL; i++) {
                           var item = _row[i];
                           var _date = item.CreateTime.toString().replace(/\//g, "");
                           var time = eval('new ' + _date);
                           var status;
                           if (item.Status) {
                               status = '是';
                           }
                           else {
                               status = '否';
                           }

                           _html += "<tr>";
                           _html += "<td>" + item.Title + "</td>";
                           _html += "<td>" + time.format('yyyy-MM-dd') + "</td>";
                           _html += "<td>" + status + "</td>";
                           _html += "<td>";
                           _html += "<a href='javascript:void(0)' onclick='statusChange(\"" + item.Id + "\")' class='operate'><span class='glyphicon glyphicon-stop'></span> " + (item.Status ? "启用" : "停用") + "</a>";
                           _html += "<a href='/CourseOtherInfo/CourseOtherInfoContentEdit?CourseId=" + item.CourseId + "&Id=" + item.Id + "' class='operate'><span class='glyphicon glyphicon-pencil'></span> 编辑</a>";
                           _html += "</td>";
                           _html += "</tr>";
                       }
                   }
                   else {
                       $(".d-page").hide();
                   }
                   tbody.html(_html);
               }, "json");
        }


        if (!!window.location.hash) {
            var _hash = window.location.hash.substr(1);
            getList(_hash);
        } else {
            getList(1);
        }

        @*$("#courseInfoList li").click(function () {
            var _typeCode = $(this).attr("id");
            window.location.href = "@Url.Action("CourseOtherInfoList", "CourseOtherInfo")?TypeCode=" + _typeCode;
        });*@

        function statusChange(id) {
            $.easyPost("/CourseOtherInfo/CourseOtherInfoStatusChange", { "Id": id },
              function (data) {
                  if (!data.result) {
                      showTips.open(data.message);
                      return;
                  }
                  getList(1);
              }, "json");
        }


    </script>
</body>
</html>
